fixed a bug with session management