Move everything into functions to clean it up.
Main function: doIt()