fixed calculation of chunk count