added null check on localstorage

Should fix #304