truncate function shouldn't delete the selected position