Added the local storage use now
Tidied up and refactored