solved exercise 7 from methods