fixed a bug in upstream in rulematchihng function