added some logics to session