replace isFunction with typeof, fix exception in IE8