Simplify logic for future expansion
Raise exception instead of sys.exit() directly
A better way to set referer