fixed a few bugs found in HW2