Synthesis of Pseudopelletierine, Mannich reaction base catalysed

The synthesis of Pseudopelletierine starts from glutardialdehyde, which reacts with methylamine and acetonedicarboxylic acid in a two-fold Mannich reaction.


This is the reaction:


![enter image description here](https://i.stack.imgur.com/S13hO.png)


I need to write the mechanism for this reaction. It needs to be under basic conditions also.


. 


MY ANSWER SO FAR:


There will be a Mannich reaction followed by a second intramolecular Mannich reaction in order to form a ring by joining al three reagents together. Finally there will be a decarboxylation to remove the carboxylic acid groups. 


This is the mechanism I have done:


![enter image description here](https://i.stack.imgur.com/StXdB.png)


![enter image description here](https://i.stack.imgur.com/ePTec.png)


Is this right? Any help would be appreciated. 




You are very close. The only issue I see is that the Mannich reaction takes place between an enol(ate) and an imine (iminium). Your mechanism goes to the hemiaminal, and then the enolate must displace a hydroxide leaving group. Essentially that's an SN2 with a hydroxide as a leaving group, which does not occur. Instead, from the hemiaminal, the nitrogen kicks out the hydroxide to form an iminium, which is a much more reactive electrophile. The enolate attacks readily. Repeat that process, decarboxylate & tautomerize twice, and you're there.


![enter image description here](https://i.stack.imgur.com/IdatB.jpg)


 3