mid refactor to centralize state

Created by  Bowei Liu  on December 20, 2020
6EXHALB3E5HP3IQVC47M4RVZE2JERJHX37GOOHPYIVAFBWSWUX7QC
Change contents