Added distinct query for TMGMT node selection