replaced all the for and for in loops in downloads.js