add factory pattern for widget creation