Modified the program to run multiple times per query.