fix the problem witch caused momory leaks