moved some client code to server side