Improved generateMoves()