refactors CLient code