fix a bug switching between tabs