fix a bug in saving flat lattice