Updated version of example_lattice.cpp