fixing events sorting