Some refactoring on array.js