Added isFunction and insertAfter