rewrote main in rust