Refactored common client code into a trait