memory allocation bug fixed. The program should be able to run
correctly.