Added a functional isValidMove method