switched ref alt in detectAI