Docstrings updated with logic of function