better upvoting algorithm to avoid race condition