Soltuion for problem #12