rewite client code in js