Fixed issue detecting endblocks