fix for an NPE caused by not checking null values