Avoid infinite loop if list is empty, ref #135