Fixed undefined variable problem