added checks for null values