edited truncate function

truncate cuts the beginning and end