Final code and plots