cleaned up the event logging code