Fix for loop not works in PhantomJS case