implemented save and restore session functionality