fix the state sharing bugs