exception handling changed to Python 3 convention + PEP 8