Update reference.py

fixing namerror in raising error