refactoring - moved event handling to separate package