refactoring the rpc service