fixing memory leak
Merge pull request #329 from wsdookadr/master

memory leak & fix