Extracted JS vote logic