new version of control algorithm