refactored main bot