Cannot read property 'format' of undefined