Added isDefined logic