checking if an element belongs to a list