modified for part2 HW3