union set function written and various other fixes