Re factored the dialog code to be more object like