broke generator code into smaller methods