Fixed move function to use improved legalMoves.