fix control loop. it used to crash after some hours.