refactored code to use ScriptInjector