fix file saving while changing index