Solution for Problem #29