Made two event listeners so that one could construct the array for the other event listener