fixed a bug in local storage logic