update the panel to have mode switch

full function, panel needs to be tuned.