Things look to be in order, but I haven't dealt with Loops over Civics too much. I know they can be a tad tricky with the whole multiple category thing going on, but you match nicely with all examples I can find.
Have you tried having each of your functions simply return 20 instead of your variable to see if they are being called properly?