Solution for Problem #22