clean up mongo function, fix quoting as much as possible