added docstrings to the functions, and some comments