Re-did part 4. Called from within ps3() function now. Problems with part 4 results are fixed now. Part 5 is done now too.