added some logic with local storage