Code for hw5 pt 1