fix a bug when list is empty