refactor to split domain logic out of a UI class