Modified for homework 3 part 3