this part here should be encapsulated in some function (finding number of blocks)