Updated for PEP 8 compliance and added docstrings