respond to code review remarks and reverted tryResolveScriptReference to resolveScriptReference