Refactored code
Fixed bug in 'toBlockData'