Added a truncate function