Added method toString for easy debugging
Fixed a bug in the cycle