refactoring consumer agent handler