improve RPC function