Reorganized everything out of main
Changed Main function