check on null before the other conditions