New engine with idle problems

,

I recently had the engine replaced in my 96 BMW 318i. It had been sitting in my garage for a year. Since the engine has been replaced it has had a lot of trouble idling. At stop signs and when I am slowly backing out of a parking spot the engine will die. If I put the car in park it will usually idle better as opposed to just being in drive and having my foot on the brake. Sometimes as the engine is struggling the whole car will shake. It seems to be worse when the car is warmed up. My mechanic said it was the old gas in the tank. He suggested I fill it up with premium gas when the tank gets down to ? full and do that 4 or 5 times. I?ve done that but it is not any better. Any suggestions or ideas about what could be wrong?

This is not a BMW specific question or answer. Is the mechanic that is telling you “bad gas” also the mechanic responsible for transfering all the parts from the old engine to the new engine and installing the new engine? in other words how do the old engine,bad gas, new engine,diagnosing mechanic fit together?

What was the warranty on the new engine? Bring it back under warranty and let him fix it.

the same shop did all of the above. this is a shop I trust and is reputable. They are just having trouble identifying the problem and I was hoping to get some ideas. also I should say that the engine I had put in was used,not new.

actually the engine I put in was used. I’m sure if it is a problem with the insallation this shop will cover it. they were just having trouble identifying the problem.