fixed KeyError problems with new version of mongodb