Tarjan with bug fix

Tarjan with bug fix