Replacing with isDefined function