Refactored ui generation