completed deleteMem function