modify to refactor totally