Code used for Howework 2.