Solution for problem #1a