Extract client code into separate file