Refactor NQueens