fixes wrong error handling