cleanup rendering function