Add a check for the size of the list