made rule_resolve better