Added code for homework 3.