main iteration loop added