This needs to be long not int since your code allows very small blocksizes, including 1.