make index/phase in saveToFile non static