attempt to solve problem 18