changed Ais to be allocated on heap