code reordered a bit and regions added