updated checkValidMove function, adjusted position of ga code