Changed to function
Added docstring