Removed redundant code and improved PEP-8 compliance