Bot handler refactoring