added for and foreach loops to log the array elements