Better code organization, and a new directive
Update function for local storage