istype(arg) will return 0 if arg is null, so the first two statements here are redundant.