moved calculations of current chunk and blocks to separate function