TypeError: Cannot read property 'trim' of undefined