Updating from localStorage to sessionStorage
Separating logic from the controller as requested by @csokol