alternative way to set hamiltonian