solution for week 5 exercise