implement Trim function
implement Trim function bug fix