minor refactoring

separating event processing stages