I REPLACED THE ENGINE AND NOW IS RUNNING TO ROUGH, P0300 WITH NEW SPARK PLUGS on 2001 Mazda Millenia

I REPLACED THE ENGINE AND NOW IS RUNNING TO ROUGH, P0300 WITH NEW SPARK PLUGS, BUT SOME TIMES IS RUNNING JUST FINE AND THEN THE CHECK ENGINE LIGHT CAME ON AGAIN. SOMEBODY CAN HELP ME?

2 answers
Check ur connection on the ignition coils,the code that u have its when u got more than one cyl missfiring
check the wires and the coil. was it a new motor or used??

Roy