isMoveValid method added.