add docstrings and comments