added else if with NULL condition check