factor out ninvoke dependency