Added code from problem #7