Use filter() method in addElement, which might not be as efficient, but
makes the filtering much easier.