Move helper function into #ifdef