Fix broken loop