fix a crash if the list is empty