first working lattice code