isolated render code from widget.js and moved to render.js