cleaning up event code