Solution for problem #53