rework event handling - not yet fully debugged