added docstring & minor changes