prevented priority inversion in part2.py and also got rid of the redundant for loop in part1.py