handling null possible null values in multiple cases