fixed heap memory deletion