Fixed undefined variable issue