script scope/type bug fix