fix undefined bug causes recreating key