moved IEnumerator implementation to a private class