extracted bgrender functionality