Updated to remove the sort and uniq on nodes as I was duplicating the environments inadvertently with a wildcard.