Refactoring logic into Client module.