fixed bugs per HW7 instructions