added docstrings; formatting