fix bug when list is empty