utils.js: fixing array handling