improved session handling