solved problem 18 with some help