factored out some parts of ui_input