fixed the validMove function