refactor localStorage methods to save message locally