fixed writing to lattice