added main program and made a few cosmetic changes