hw2 implemented