added Error Dialog and refactored source code.