Solution for Problem #30