modify get_region logic to prevent premature exit