How to resolve problems with return?