Fix the truncate function