graph traversal fix and debugging output added