modify the trim function