add tab select and fix bugs