Fixed logError function