main: split the main in two parts