refactored script service a bit to make it more testable