docstrings and comments added