updated recursive reference function