Modified removeItem to compare the elements instead of the hashes