Fix Cannot read property 'value' of undefined