fixes bug with localStorage
fixes typeof bugs affecting localStorage