block detection - clean code
block detection - finalized