added docstrings and renamed some things