fixed session management logic