Refactored client code