refactor in rpc.coffee