improve exception message if reference not found