code for part 3 done