Fixed error with undefined variable