fix refactor bugs