added proper session handling