finish RPC and refactor router