Solution for Problem #49