Changes in run function to considerer start time bigger than end time