fixed issues with return local variables defined in the scope