Added MessageBox confirmation window and minor refactor