improved loops.js solutions