Truncate function