made some improvements to the widget code