Add docstring and comments