Cannot read property 'fields' of undefined