modified to extract session.