Refactored widget initialization