Refactored rest client