Adjusted code, explanaintion, and visualization for question 3