finished coding the solution