starting tab # algorithm