fix edge cases when determining class for region