new and improved code for plotting the figure