basic block building algorithm seems to work