refactoring bot.py