Built out more of the high level logic for the main function