replace list(set(...)) with itertools so atoms are ordered correctly