code from part 3 added