code cleaning, dynamic memory leak fixed