display results refactored with foreach loop