cleaning up RPC code