Fixed loop issue and changed the data type for sites to hash instead of array.