revise the truncate code