added var to for loops in mag-dom