Refactoring to enclose main functionality into class and use event service to load mappings