fix exit condition for next method