update main to handle io