Add a check if the list is not empty