factored out pieces of ui_input to simplify