Function updated, leading and trailing characters removed