update trim function