code cleanup
better organization of code, self explaining main.c code