refactoring y implemented save to disk