cleaned up code for hw2