Fix bug of truncate function