changed order to avoid flicker