added local storage, fixed bugs