fixed StackOverflowException occuring when using regions