Refactor question 1.3 and fix plot