added docstring and fixed some small formatting