redesigned for HW4