check loop condition before render

cc @rochoa @fdansv