correct truncate function