modified according to HW6