added check for null values