fix bugs when change mode