Added dialog window and some logic