in SJF, adding logic to decode the events.