fixed logic bug

fixed logic bug in reference processing