PEP8 Compliant except needed long lines and better exception handling