switched from isFunction to isUndefined