add docstrings, fixed indentation