fixed a variables in errorgui and refactored