Separate main.c into two files & bug fixed.