fix error when list is empty