fix undefined bug