Changed from setInterval (which can step on itself and cause no delay between executions, potentially bad) to setTimeout where the getSchedule function resets the next timer so that it will continue executing. This way it has a fixed delay between executions in case of long execution time.