extract method to form a session object