Refactored code placing items into an array and iterating through it.