If the car is throwing a code, check it out. Then address the code, it could be a Mass Flow issue, cam sensor issue, tune up issue, crank sensor, etc. Run a diagnostic test and go from there. Usually costs $100 and most mechanics will do this first anyway to save time and money.