Fix wrong error logging