complete hw2, with bug