add error handling when get 401
error handling with HTTP 401
replace the duplciate code
fix issue #14
update version