refactor, make arrays of objects work