Refactor JavaScript for votables