refactoring plot scripts