improve condition of flipping s:idx