modified stack and Get3RdLastNode