fix trim function