adds logic to find smallest number of moves