Fixing memory leak (which wasnt important right now as the program terminates anyway right after that but maybe it gets complicated in future uses)