Finish HW2
fixed one bug in n