adding an is_function check to prevent errors