Neat solution to problem021