Refactor to enable redrawing of plot