moved printb inside the GState class and collapsed the two loops in swap