factor out ui stuff