corrected undefined variable error