refactoring code for add_voting