refactor and start using dispatcher pattern