added a check for null on the list