improve memory management using delete