refactor valid sudoku