the throttle poistion sensor is the potentiometer i would check thats working ok first that regulate the amount of air being allowed in to the engine,I would disconnect the afm if the car doesnt cut out you can rule that out,how many o2 sensors has the legacy got is there one on the up pipe and one on the exhaust side.