fix swap(i, i) since it caused crashes