Making a  Foreach function