Updated to sort events by time