Changed order of session check