seperating out the headnode stuff from the main program