tweaked main program flow