improved memory efficiency by checking bag permissions early

the efficiency gains should be insignificant, but I suppose it also
makes slightly more sense (readability-wise) this way