Something about this is fishy - if there isn't an error, and there isn't a `doc`, then it passes `undefined` to the callback.  Is that intentional?