put write soln in its own function