Refactoring for MessageBox