main program logic