Move dialog logic to its own module