adding methods to solve hw2