Next_step() function sketch