Update/Finished main code