optimize render loop