refactored client code