Memory leak fixed + exception thrown instead of omiting it