first code for memory management