updated code to accomodate changing lattice constants