Fixed undefined variable error