Fixed Out of Bound exception in the render loop