render loop refactor