using recursive prefix thing