added docstrings to functions and more thorough comments throughout code