Fix error when a given either an empty list or a list with only one item