Added trim() to truncate function