Refactored code using Array and .each method