Changed the inner loop of the render function to be a little easier to read