fix for: Cannot read property 'remaining' of undefined