Refactoring the bot