fix undefined varibale bug