add and use truncate function