two loops are not necessary, would put this under the loop above as iterator indices are the same..