reimplement add_circuit