calculate Aprod2 more efficiently