clean main and add typedef for more transparence