Refactor data functions out of script.js