Added inner cycle WHILE