Fix crash when list is empty