another solution to week-5 assignment-4.