fixes some errors about tab switch