added saving values when error