plot2 and some refactoring