fix undefined variable error