I was getting an intermittent bad idle and would get a crank position sensor code, the code would clear and idle normally, but would return. A put a new crank position sensor in, which cured the problem. I noticed that there was some crud on the tip of the old sensor once I had removed it, as I already had the new one I installed it, but it may be worth you removing and cleaning yours before buying a new one.