Solution for Problem #23