Solution for Problem #27