Moved import to try/except statement