use inspect.isfunction instead of type comparison