redoing the logic for tabbing