Pulled in code from pre_global. it makes the code more understandable as all conditions are in one spot.