TypeError: Cannot read property 'total' of undefined