modified for homework 6 part 2