Added localStorage for persistence + refactoring