refactoring and specing the determine_next_step method