wrote function to check if chessboard is valid