fixed error when list is empty