fix a return statement ending code prematurely