Added extra check that the result is not null. - seen a null pointer for this on crittersism