wrote insert_block function