delay im(a) calculation

The change in variables threw me off. I see what you are doing. How about the following patch to what you've done?