fix error when localStorage setitem failed for any rason