Final for HW4 -- not my best work :-/