This scoping of `ui` kinda freaks me out.