the second algorithm

based on bcTable and textWindow