code for homework 2