fixed saving algorithm