Fix variable name typo, add logging