rewrite from scratch with Flat UI