Rewrite and finish implementing the client code