update code for part 3 of p1