move constants outside try/except block