refactor rest-client