almost finished with preliminary event code