script as function
added docstrings