fixed wrong bracketing in error handling