triangle_facts refactoring