modified for hw6 part 2