Added additional foreach statements to make the content more dynamic.