use a preconditions to check if the list is null