improved docstring
exception handling