cleanup .toArray() and .each()