refactoring voting script