Changed elem lists to sets