there is a bug with this, the correct statement is "..f(state.isOpened()){..." and not session.