simple C++ code (avoiding timeouts??)