move KeyboardInterrupt to main():