added checking for localstorage