Code refactoring in rest client implementation