minor changes (additional check to avoid runtime errors)