Fixed undefined variable logging problem