Solve the return with value inside a generator error