Cannot read property 'total' of undefined