Update render.c

updated render logic