corrected formula for calculating numBlocks
fixed yOffset calculation