forEach array utility function