finished maintain session functionality