added check for valid move