added data block, mem overflow check and better error print