Corrected a bug on switching tab