Organized and cleaned the code