fixed bugs caused by refactor