refactored voting code