Converted ScriptRunner to Scala code