updated memory management