refactoring: introduced CommandHandler and EventHandler object and delegated calls to those objects