I think this would be cleaner if we have `remaining` already instantiated, and then check for `remaining.length` on line 148.