Solution for Problem #50