Completed the foreach function exercise