working algorithm soln