refactored bot