exception handling changed to Python 3 and PEP 8