finish implementing basic block detection algorithm