Added an end_solution function