Changed to fixed number of iterations and put output var at the botton to return output