Added Docstring and added exception handlers