HW5 solution