Fix wrong error handles