changed id comparisons to Number-based as it is a string value. It was resulting in wrong trees when the derived table's number was a two digit number.