Simplied function calls and made them nested.