Handle end of survey case
Handle grouped repeats
Refactor some conditionals