Start of RPC logic