fixed lattice_outside so that distance_to_boundary tracks as expected