chatbar code optimize