add control in algorithm