check if parameter is null before adding it to the list