Idle 2004 nissan

My nissan 2004 sentra spec v 2.5L.Has a idle problem it revs up n down.i had a code on it.it was po507 idle air control vavle i was told to replace it so i did. and i still have the same problem.it was cheack for vaccum and smoke for leak they said their none. i change the 02 sensor.i dont know what to do now. i really dont want to go to the dealer cost to much.any sugestion.thany you

The DTC P0507 does NOT say, “Change the idle air control valve”. P0507 is defined as: “Idle air control system RPM higher than expected”. You kinda noticed that, already, didn’t you?
The problem could still be vacuum leaks. Check that the large intake tube is on airtight. Disconnect all the vacuum lines, and vacuum hoses (including the brake booster hose, the pcv hose, plug the egr port to the intake), and plug the ports where you disconnected them. Run the engine. Results?