fix to chain_hamiltonian, now tested