tweak the index writing to be safer