update code (memory leaks, remove some codes.. )