Fixed the moves to stop looking when invalid move found.