Refactor for util.rpc