slight rework of logic; don't check for null where impossible