refactoring code to a plotter library of my own