You should be checking for emptiness, not if it is defined.