Replace build-in 'trim' function with custom method.