Refactored bot.py