Move script into its own file and fix window.setInterval bug
Merge pull request #1 from reubenmorais/master

Fixes to make refactored version work in simulator