start code refactoring with events and a master controller