improved load() function
fixed memory leak