Fixed removeElement to always remove the FIRST occurrence of an element