improved speed of region detect