cleaned up code, added docstrings