Review the following code and generate or update docstrings for all functions where they would be useful. Include output and parameter descriptions. 