working code

code now works in 1-site and periodic boundary condition cases