fixed semicolon
used DOM everywhere
curl must follow 302
ignore loop with non data