Fixed window.localStorage "null" error