refactor to fix unification query bug in mongo node