still refactoring plot script