Implemented the validMove method.