main program and debugging