working function. but slow because of the blocks expanding. lot of IO!