removed duplicated loop