Added documentation
Added logic to handle different HTTP responses.