fix bugs and added local storage