It is freezing because script proccess huge data and takes time. with 1000 data, it takes about 32secs to complete.