lattice refactor