Trim function in general