refactor plotter