Solving week 4 problem