Added code and plot for task 3