Added checking of null values.