2001 Mercury cougar engine trouble

2001 mercury cougar, 91000 miles. The engine was sputtering and killed itself once, also the engine missed every time I drove it. I replaced the plugs and wires, which fixed the engine missing. I replaced the fuel filter (which I thought my mechanic had already done, but I was wrong) which fixed the sputtering. I just replaced the coil pack which made the car run a lot smoother. Now the car will die when revved up from an idle. Please please help like I said the car runs good when driving, but dies at an idle when the engine is revved. I can’t seem to diagnose this engine help is much appreciated. Thank you