Refactored Sudoku code to make understandable