fix bugs do to refactoring