refactoring + pdf build script