Modified main.run to handle intervals