add ref to function appropriately