Added exit code check
Formatting
Added docstrings
Formatting