added a truncate function