Make extract-fact function more versatile