add condition to end the manager_loop