fixed docstring and error catching