vote algorithm