Finished Main Code