Without looking at the implementation, its hard to know what `elem1` and `elem2` mean in this context. Could the comment spell out more exactly what they do?