Making the JS function execute continuously after number of miliseconds