Fix wrong error check