Refactored widget rendering