optimizate memory usage for aicp