reogranize bot controller code