swapped flag within for structure fixed