copied voting code from legacy