Changed plotting code to plot points first to make it easier to walk through the code