optimize bots logic