update the possible moves algorithm