Made the dialog function a little better.