wrote truncate code