Implement previous selection management feature.

- use localStorage
- refactor.