Adding main funcitons and debugging functions