Cleaning main code ! Need to clean it better