implement voting algorithm