finished problem 6, clean working example