Fixed try/except error
Removed unnecessary global statement.