Refactor localStorage