removed element counter and added peeking at the head and tail of list