Refactored plot2 and plot3 to extract functions
Added plot4