add 'if session == nil' case