improved voting algorithm