correction delete  (no more memory leak) and error handling