Fixed error message logging