added exception handling and RestResponse class for response