corrected bugs and add tab switch