Fix the bug of trim function