Refactor: split state checks into own function, consolidate dialogue into repository.