made nextPhase a variable