Move interval function to own js file