roughly implement the client