Fixing the render loop