added code and plots