refactored to iterate and pull pattern