Cleaned the main code