Code for Part 4