better approach to printing the solutions