refactoring class
refactor and add save feature