Re-ordering conditional to check for NULL first