fix some bugs from refactor