Move logError to the very top