completed with docstrings and timing