Use loop over variable names to eliminate duplicate code.