refactoring code into widgetytpe.js