moving code to plot builder