refactoring and event bus implementation