Fix for RETURN_END_IF bug