Refactored localStorage function into modules