improve session handling