added error handling to rpc library