fix undefined var error