Fixing exception vs null in scripting functions