rewrote main