Racing engine

I have a 2003 Jeep Grand Cherokee with 70k miles. The engine races when in park when it is started , going up to 1900 rpms or so. Sometimes it comes down below 1000 and sometimes it doesn’t. Sometimes it races up and down while being driven . Neither the dealer nor two mechanics could figure out what it is ; although one mechanic changed some part out , the name of which now escapes me , but it may have been some electronic part . The check engine light is on continually . Has anyone had that problem ?